package com.suncreate.radarscan.web;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.suncreate.radarscan.service.AlertEventDetectService;
import com.suncreate.radarscan.service.RadarStatisticService;

@Controller
@RequestMapping(value="/eventdetect")
public class AlertEventDetectController {
	@Autowired
	AlertEventDetectService alertEventDetectService;
	
	@Autowired
	RadarStatisticService statisService;
	
	@RequestMapping(value="/startStatistic")
	public ModelAndView statisticStart() {
		
		String message;
		try {
			message = "成功启动统计分析服务";
			statisService.startStatistic();
		} catch (Exception e) {
			message = "启动统计分析服务失败";
			e.printStackTrace();
		}
		return new ModelAndView("index","statistic",message);
	}
	
	@RequestMapping(value="/startEvent")
	public ModelAndView eventDetectStart() {
		String message;
		try {
			message = "成功启动事件检测服务";
			alertEventDetectService.startEventDetect();
		} catch (Exception e) {
			message = "启动事件检测服务失败";
			e.printStackTrace();
		}
		return new ModelAndView("index","eventdetect",message);
	}
	
	@RequestMapping(value="/login")
	public ModelAndView login() {
		return new ModelAndView("index");
	}
}
